import heapq


def heap_sort(nums: list[int]):
    """堆排序"""
    min_heap = []
    # 入堆
    for num in nums:
        heapq.heappush(min_heap, num)
    # 出堆
    for i in range(len(nums)):
        nums[i] = heapq.heappop(min_heap)


if __name__ == "__main__":
    nums = [4, 1, 3, 1, 5, 2, 9, 8, 6, 7]
    heap_sort(nums)
    print("排序完成后 nums =", nums)
    # 排序完成后 nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]
